package com.sinosoft.hydra.um.domain.model;

import cn.com.sinux.spring.utils.ValidatorUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.sinosoft.hydra.um.services.component.dataCollect.DataResult;
import org.apache.commons.lang.time.DateFormatUtils;

import java.io.Serializable;
import java.util.*;

/**
 * Created by Administrator on 2016/8/15.
 */
public class ParseData implements Serializable{

    private List<String> times;
    private List<DataResult.Label> labels;
    private Map<String, List<Double>> data = new HashMap<String, List<Double>>();

    public List<DataResult.Label> getLabels() {
        return labels;
    }

    public void setLabels(List<DataResult.Label> labels) {
        this.labels = labels;
    }

    public void setTimeLineData(List<DataResult.TitleLineData> titleLineDatas){
        this.times = new ArrayList<String>();
        for(DataResult.TitleLineData titleLineData : titleLineDatas){
            if(ValidatorUtils.isArrayEmpty(times)){
                for(Date time : titleLineData.getTimes()){
                    this.times.add(DateFormatUtils.format(time, "yyyy-MM-dd HH:mm:ss"));
                }
            }
            data.put(titleLineData.getTitle(), titleLineData.getDoubles());
        }
    }

    public List<String> getTimes() {
        return times;
    }

    public Map<String, List<Double>> getData() {
        return data;
    }
}
